<%@ page language="java" import="java.util.*,java.sql.*,java.math.*"
	contentType="text/html; charset=utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<jsp:useBean id="db" class="connBean.ConnDB" scope="page" />

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>欧米购商城-商品详情</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">


		<link rel="stylesheet" href="css/style.css" type="text/css"
			media="all" />
		<!--[if lte IE 6]><link rel="stylesheet" href="css/ie6.css" type="text/css" media="all" /><![endif]-->

		<meta name="keywwords"
			content="Shop Around - Great free html template for on-line shop. Use it as a start point for your on line business. The template can be easily implemented in many open source E-commerce platforms" />
		<meta name="description"
			content="Shop Around - Great free html template for on-line shop. Use it as a start point for your on line business. The template can be easily implemented in many open source E-commerce platforms" />

		<!-- JS -->
		<script src="js/jquery-1.4.1.min.js" type="text/javascript">
</script>
		<script src="js/jquery.jcarousel.pack.js" type="text/javascript">
</script>
		<script src="js/jquery-func.js" type="text/javascript">
</script>
		<!-- End JS -->

		<script>
$(function() {
	var t = $("#text_box");
	$("#add").click(function() {
		t.val(parseInt(t.val()) + 1)
		setTotal();
	})
	$("#min").click(function() {
		t.val(parseInt(t.val()) - 1)
		setTotal();
	})
	function setTotal() {
		$("#total").html((parseInt(t.val()) * 3.95).toFixed(2));
	}
	setTotal();
})
</script>


		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

	</head>
	<body>
		<style type="text/css">
/* CSS Document */
#mytable {
	width: 700px;
	padding: 0;
	margin: 0;
}

caption {
	padding: 0 0 5px 0;
	width: 700px;
	font: italic 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
	text-align: right;
}

th {
	font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
	color: #fff;
	border-right: 1px solid #C1DAD7;
	border-bottom: 1px solid #C1DAD7;
	border-top: 1px solid #C1DAD7;
	letter-spacing: 2px;
	text-transform: uppercase;
	text-align: left;
	padding: 6px 6px 6px 12px;
	background: #8b0000 no-repeat;
}

/*power by www.winshell.cn*/
th.nobg {
	border-top: 0;
	border-left: 0;
	border-right: 1px solid #C1DAD7;
	background: none;
}

td {
	border-right: 1px solid #C1DAD7;
	border-bottom: 1px solid #C1DAD7;
	background: #fff;
	font-size: 11px;
	padding: 6px 6px 6px 12px;
	color: #4f6b72;
}

th.spec {
	border-left: 1px solid #C1DAD7;
	border-top: 0;
	background: #fff no-repeat;
	font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
}

#content {
	float: left;
	width: 724px;
}

#sidebar {
	float: right;
	width: 226px;
}

.search {
	min-height: 700px;
}

.search-addcart {
	width: 100px;
	background: url(images/cart-link.png) no-repeat 0 0;
	border: 0;
	color: #fff;
	height: 27px;
	display: block;
	line-height: 26px;
	cursor: pointer;
	margin: 12px 0 10px 0;
}

#slider {
	height: 700px;
	position: relative;
	overflow: hidden;
	list-style-type: none;
	border: 0
}

#slider-holder {
	width: 231px;
	height: 383px;
	position: relative;
	overflow: hidden;
	border: 0
}

#slider-holder .jcarousel-clip {
	width: 231px;
	height: 383px;
	position: relative;
	overflow: hidden;
}

#slider-holder ul {
	width: 231px;
	height: 383px;
	position: relative;
	overflow: hidden;
	list-style-type: none;
}

#slider-holder ul li {
	width: 231px;
	height: 383px;
	position: relative;
	overflow: hidden;
	float: left;
}

#slider-nav {
	position: absolute;
	top: 350px;
	left: 120px;
	z-index: 2;
}

#slider-nav a {
	font-size: 0;
	line-height: 0;
	text-indent: -4000px;
	width: 10px;
	height: 10px;
	border: solid 1px #8b0000;
	background: #8b0000;
	float: right;
	margin-right: 5px;
}

#slider-nav a:hover,#slider-nav a.active {
	background: #fff;
}

.datas {
	
}

.datas ul {
	list-style-type: none;
}

.datas ul li {
	position: relative;
	padding: 1px;
	border: solid 1px #dedede;
	float: left;
	width: 231px;
	margin-right: 9px;
	height: 383px;
	overflow: hidden;
}

.datas ul li2 {
	position: relative;
	padding: 1px;
	border: solid 1px #dedede;
	float: left;
	width: 465px;
	margin-right: 9px;
	height: 383px;
	overflow: hidden;
}

.datas ul li.last {
	margin-right: 0;
}
</style>

		<%
			request.setCharacterEncoding("UTF-8");
			String p_id = request.getParameter("p_id");
			String ref = request.getHeader("REFERER");
			int pstatus = 0;
			float finalprice = 0;
		%>
		<jsp:include page="customerService.jsp"></jsp:include>
		<!-- Shell -->
		<div class="shell">

			<!-- Header -->
			<div id="header">
				<h1 id="logo">
					<a href="index.jsp">欧米购</a>
				</h1>
				<!-- Cart -->
				<div id="cart" align="center">
					<%
						if (session.getAttribute("username") == null
								|| session.getAttribute("username") == "") {
					%>您好，您还未登录！
					<div class="cl">
						&nbsp;
					</div>
					<a href="login.jsp" class="c2-link">[登录]</a>
					<a href="addUser.jsp" class="c2-link">[免费注册]</a>
					<%
						} else {
					%>欢迎您，<%=session.getAttribute("username")%>
					<a href="logout.jsp" class="c2-link">[退出]</a>
					<div class="cl">
						&nbsp;
					</div>
					<a href="personalData.jsp" class="c2-link">我的欧米购</a>
					<a href="shoppingCart.jsp" class="cart-link">我的购物车</a>
					<%
						}
					%>
				</div>
				<!-- End Cart -->

				<!-- Navigation -->
				<div id="navigation">
					<ul>
						<li>
							<a href="index.jsp">主页</a>
						</li>
						<%
							db.OpenConn();
							db.createStmt();
							String sql = "select * from main_type";
							ResultSet rs = db.Query(sql);
							while (rs.next()) {
						%>
						<li>
							<a href="index_main_Type.jsp?maintype_id=<%=rs.getInt("t_id")%>"><%=rs.getString("t_name")%></a>
						</li>
						<%
							}
							db.closeStmt();
							db.closeConn();
						%>
					</ul>
				</div>
				<!-- End Navigation -->
			</div>
			<!-- End Header -->

			<!-- Main -->
			<div id="main">
				<!-- End Content Slider -->

				<div id="sidebar">

					<!-- Search -->
					<div class="box search">
						<h2>
							其他商品
							<span></span>
						</h2>
						<div class="box-content">
						    <marquee srolldelay="100" direction="up" loop="10" height="600" width="300" scrollamount=10 onmouseover="this.stop()" onMouseOut="this.start()">
						    <%db.OpenConn();
							    db.createStmt();
							    String topsql="select * from product";
							    ResultSet products2=db.Query(topsql);
							    while(products2.next()){
							    String pid=products2.getString("p_id");
							    String name=products2.getString("p_name");
							    String images=products2.getString("p_image");
							    String []image=images.split(";");
							     %>
								<li>
									<a href="index_ProductDetail.jsp?p_id=<%=pid %>"><img src="images/<%=image[0] %>" alt="" /><%=name %></p>
									</a>
								</li>
								<%}
								db.closeStmt();
								db.closeConn();
								 %>
						    </marquee>
						</div>
					</div>
					<!-- End Search -->

				</div>
				<!-- End Sidebar -->


				<!-- Content -->
				<div id="content">
					<%
						db.OpenConn();
						db.createStmt();
						String psql = "select * from product where p_id='" + p_id+"'";
						ResultSet products = db.Query(psql);
						if (products.next()) {
							float price = products.getFloat("p_price");
							String p_images = products.getString("p_image");
							String[] images = p_images.split(";");
							pstatus = products.getInt("p_status");
					%>
					<!-- Products -->
					<div class="datas">

						<ul>
							<li>
								<div id="slider" class="box">
									<div id="slider-holder">
										<ul>
											<li>
												<img src="images/<%=images[1]%>" alt="" />
											</li>
											<li>
												<img src="images/<%=images[1]%>" alt="" />
											</li>
											<li>
												<img src="images/<%=images[1]%>" alt="" />
											</li>
											<li>
												<img src="images/<%=images[1]%>" alt="" />
											</li>
										</ul>
									</div>
									<div id="slider-nav">
										<a href="#" class="active">1</a>
										<a href="#">2</a>
										<a href="#">3</a>
										<a href="#">4</a>
									</div>
								</div>
							</li>
							<li2>
							<form method="post" action="checkAddProToCart.jsp?p_id=<%=p_id%>">
								<table border=0 width="100%" height="100%">
									<tr>
										<td width="20%">
											商品名称：
										</td>
										<td><%=products.getString("p_name")%></td>
										<td rowspan="6" valign="bottom">
											<input type="button" value="返回上级" class="search-submit"
												onclick="javascript:window.location='index.jsp'" />
										</td>
									</tr>
									<tr>
										<td>
											价格：
										</td>
										<td>
											<%
												if (pstatus == 2) {
											%>￥
											<s><%=price%></s>
											<%
												} else {
														out.print("￥" + price);
													}
											%>
										</td>
									</tr>
									<tr>
										<td>
											特价：
										</td>
										<td>
											<%
												if (pstatus == 2) {
														float tejia = 0.9f;
														finalprice = price * tejia;
														BigDecimal b = new BigDecimal(finalprice);
														out.print("￥"
																+ b.setScale(2, BigDecimal.ROUND_HALF_UP)
																		.floatValue());
													} else {
														out.print("无");
														finalprice = price;
													}
											%>
										</td>
									</tr>
									<tr>
										<td>
											库存量：
										</td>
										<td><%=products.getInt("p_quantity")%></td>
									</tr>
									<tr>
										<td>
											数量：
										</td>
										<td>
											<input name="finalprice" type="hidden"
												value="<%=finalprice%>" />
											<input id="min" name="" type="button" value=" - " />
											<input id="text_box" name="quantity" type="text" value="1"
												maxlength="5" size="5" />
											<input id="add" name="" type="button" value=" + " />
										</td>
									</tr>
									<tr>
										<td valign="bottom">
											<input type="button" value="立即购买" class="search-submit" />
										</td>

										<td valign="bottom">
											<input type="submit" value="      加入购物车"
												class="search-addcart" />
										</td>
									</tr>
								</table>
								</form>
								</li2>
						</ul>
					</div>

					<!-- End Products -->
					<form action="addComments.jsp?p_id=<%=p_id %>" method="post">
					<table border=0 width="713">
						<%
							if (session.getAttribute("username") == null
										|| session.getAttribute("username") == "") {
						%>
						<tr>
							<td align="center" width="70%" height="50">
								商品详情
							</td>
						</tr>
						<tr>
							<td valign="top"><%=products.getString("p_description")%></td>
						</tr>
						<tr>
							<td colspan="2">
								您还未登录，请进行
								<a href="login.jsp">登录</a>后再评论！
							</td>
						</tr>
						<%
							} else {
						%>
						<tr>
							<td align="center" width="70%" height="50">
								商品详情
							</td>
							<td align="center" valign="bottom" rowspan="3">
								<input type="reset" value="清空" class="search-submit" />
								<input type="submit" value="评论" class="search-submit" />
							</td>
						</tr>
						<tr>
							<td valign="top"><%=products.getString("p_description")%></td>
						</tr>
						<tr>
							<td>
								编辑评论
								<textarea cols="110" rows="6" name="content"></textarea>
							</td>
						</tr>
						<%
							}
						%>
					</table>
					</form>
					<%
						}
					%>
					<table width="713">
						<caption>
						</caption>
						<tr>
							<th width="110" align="center">
								评论人
							</th>
							<th width="65%" align="center">
								评论内容
							</th>
							<th>
								评论时间
							</th>
						</tr>
						<%
							String comsql = "select cm.cm_id,cm.p_id,cu.c_name,cu.c_header,cm.cm_message,cm.cm_time,cm.cm_pass from comment as cm left join customer as cu on cm.c_id=cu.c_id where cm.p_id='"+ p_id + "' and cm.cm_pass=1";
							System.out.println(comsql);
							ResultSet comments = db.Query(comsql);
							int count=0;
							while (comments.next()) {
							count++;
						%>
						<tr>
							<td align="center">
								<img src="images/<%=comments.getString("c_header")%>"
									width="100" height="100" />
								<%=comments.getString("c_name")%></td>
							<td><%=comments.getString("cm_message")%></td>
							<td><%=comments.getString("cm_time")%></td>
						</tr>
						<%
							}
							db.closeStmt();
							db.closeConn();
							if(count==0)
							{
							%>
							<tr>
							  <td colspan="3" align="center" >暂无任何评论！</td>
							</tr>
							<%
							}
						%>
					</table>
				</div>
				<!-- End Content -->

			</div>
			<!-- End Main -->

			<!-- Side Full -->
			<div class="side-full">

				<!-- Text Cols -->
				<div class="cols">
					<div class="cl">
						&nbsp;
					</div>
					<div class="col">
						<h3 class="ico ico1">
							Donec imperdiet
						</h3>
						<p>
							Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
							imperdiet, metus ac cursus auctor, arcu felis ornare dui.
						</p>
						<p class="more">
							<a href="#" class="bul">Lorem ipsum</a>
						</p>
					</div>
					<div class="col">
						<h3 class="ico ico2">
							Donec imperdiet
						</h3>
						<p>
							Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
							imperdiet, metus ac cursus auctor, arcu felis ornare dui.
						</p>
						<p class="more">
							<a href="#" class="bul">Lorem ipsum</a>
						</p>
					</div>
					<div class="col">
						<h3 class="ico ico3">
							Donec imperdiet
						</h3>
						<p>
							Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
							imperdiet, metus ac cursus auctor, arcu felis ornare dui.
						</p>
						<p class="more">
							<a href="#" class="bul">Lorem ipsum</a>
						</p>
					</div>
					<div class="col col-last">
						<h3 class="ico ico4">
							Donec imperdiet
						</h3>
						<p>
							Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
							imperdiet, metus ac cursus auctor, arcu felis ornare dui.
						</p>
						<p class="more">
							<a href="#" class="bul">Lorem ipsum</a>
						</p>
					</div>
					<div class="cl">
						&nbsp;
					</div>
				</div>
				<!-- End Text Cols -->

			</div>
			<!-- End Side Full -->



			<!-- Footer -->
			<div id="footer">
				<p class="left">
					<a href="index.jsp">Home</a>
					<span>|</span>
					<a href="#">Support</a>
					<span>|</span>
					<a href="#">My Account</a>
					<span>|</span>
					<a href="#">The Store</a>
					<span>|</span>
					<a href="#">Contact</a>
				</p>
				<p class="right">
					&copy; 2015 OMEGO Shopping Design by &nbsp;
					<a href="#" target="_blank"
						title="The Sweetest CSS Templates WorldWide">欧米购创意小组</a>
				</p>
			</div>
			<!-- End Footer -->

		</div>
		<!-- End Shell -->


	</body>
</html>
